-
+
/
A
*
D
E
B
C
Our goal: build a complex tree like this one.

The Building Block

The `TreeNode` Class

Before building an expression tree, we need its fundamental component: a node.

Each node holds a value (e.g., `*` or `A`) and has `left` and `right` pointers, which makes the structure perfect for representing binary operations.

class TreeNode:
    """A simple node class for our expression tree."""
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None